# -*- coding:utf-8 -*-

from server.action.batchBase import batchBase
from server.util import sqlBuild, stringUtil
import uuid, time


class breg(batchBase):  # 建立连接
    @batchBase.idChecked
    def action(self, data, d):
        baId = data[0]
        lb = stringUtil.redis_key_name(baId)
        isHave = self.re.lindex(lb, 1)
        if len(isHave) == 0:
            self.re.lset(lb, 1, "lose")  # 状态更新为失去
            d.callback((1, ("brgr", "no"), baId))
        else:
            self.re.lset(lb, 1, 0)  # 状态更新为0
            d.callback((1, ("brgr", "ok"), baId))
